package com.xingzhe.pengji.framework.pager;

import com.xingzhe.pengji.framework.bean.BaseObj;

public class Pager extends BaseObj {
	private int pageCount = 0;
	private int itemCount = 0;
	private int pageNumber = 1;
	private int pageSize = 10;
	public static final int DEFAULT_PAGE_SIZE = 10;
	private boolean pageAble = true;
	private int firstResult;

	public Pager() {

	}

	public Pager(int itemCount) {
		this.itemCount = itemCount;
	}


	public void calc() {
		pageCount = itemCount % pageSize == 0 ? itemCount / pageSize : itemCount / pageSize + 1;

		firstResult = (pageNumber - 1) * pageSize;
	}

	public boolean isPageAble() {
		return pageAble;
	}

	public void setPageAble(boolean pageAble) {
		this.pageAble = pageAble;
	}

	public int getItemCount() {
		return itemCount;
	}

	public void setItemCount(int itemCount) {
		this.itemCount = itemCount;
	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public int getPageNumber() {
		return pageNumber;
	}

	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	@Override
	public String toString() {
		return ("\ntotalPages:" + pageCount + "\ntotalObjects:" + itemCount + "\npageNumber:" + pageNumber
				+ "\npageSize:" + pageSize + "\npageAble:" + pageAble + "\nfirstResult:" + firstResult);
	}

	public int getFirstResult() {
		return firstResult;
	}

	public void setFirstResult(int firstResult) {
		this.firstResult = firstResult;
	}

}
